package com.ionehe.group.common.notify.autoconfigure;

import com.ionehe.group.common.notify.configure.NotifyConfiguration;
import com.ionehe.group.common.notify.message.factory.Factory;
import com.ionehe.group.common.notify.rocketmq.factory.AsyncFactory;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;

/**
 * Copyright (c) 2021 ionehe.com
 * Date: 2021/4/21
 * Time: 1:30 下午
 *
 * @author 2021年 <a href="mailto:a@ionehe.com">秀</a>
 * 【自动装配配置类】
 */

@Configuration
@ComponentScan({"com.ionehe.group.common.notify"})
@EnableConfigurationProperties({NotifyConfiguration.class})
public class NotifyAutoConfiguration {
    @Bean
    @ConditionalOnMissingBean
    @ConditionalOnProperty(prefix = "notify", name = {"vendor"}, havingValue = "rocketmq")
    public Factory getFactory(NotifyConfiguration configuration) {
        return (Factory) new AsyncFactory(configuration);
    }
}
